package com.minyifang.wcspf.work.ui.goods.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.minyifang.wcspf.R;
import com.minyifang.wcspf.work.ui.goods.model.GoodsBanner;

import java.util.List;

import cn.jzvd.JZVideoPlayer;
import cn.jzvd.JZVideoPlayerStandard;

public class PicPagerAdapter extends PagerAdapter {
        private List<String> mBannerList;
        private Context mContext;

    public PicPagerAdapter(List<String> bannerList, Context context) {
        mBannerList = bannerList;
        mContext = context;
    }

    @Override
        public int getCount() {
            return mBannerList.size();
        }

        @Override
        public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
            return view == object;
        }

        @NonNull
        @Override
        public Object instantiateItem(@NonNull ViewGroup container, int position) {
            View layout = LayoutInflater.from(mContext).inflate(R.layout.item_pager_pic, null);
            ImageView imageView = layout.findViewById(R.id.iv_picture);
            container.addView(layout);
            Glide.with(mContext).load(mBannerList.get(position)).apply(new RequestOptions().placeholder(R.mipmap.img_place_holder)).into(imageView);
            return layout;
        }

        @Override
        public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
            container.removeView((View) object);
        }
    }